package com.ssj.ssj.modules.man.controller;

import com.ssj.ssj.constant.Constants;
import com.ssj.ssj.modules.man.entity.SUser;
import com.ssj.ssj.modules.man.service.LoginService;
import com.ssj.ssj.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class LoginController {

  @Autowired
  LoginService loginService;

  @PostMapping("/login")
  public R login(@RequestBody SUser loginBody) {
    R ajax = R.ok();
    // 生成令牌
    String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid());
    ajax.put(Constants.TOKEN, token);
    return ajax;
  }

}
